Print a list from n times 1 to n times 9


Posted by Christy on 2022-04-19

Description: Write a function named table that accepts a number n and print the list from n times 1 to n times 9

table(1)
1*1 = 1
1*2 = 2
1*3 = 3
1*4 = 4
1*5 = 5
1*6 = 6
1*7 = 7
1*8 = 8
1*9 = 9

table(7)
7*1 = 7
7*2 = 14
7*3 = 21
7*4 = 28
7*5 = 35
7*6 = 42
7*7 = 49
7*8 = 56
7*9 = 63

Answer:

function table(n) {
  for (let i = 1; i <= 9; i++) {
    console.log(n + "*" + i + "=" + n * i);
  }
}

table(3);









Related Posts

簡明約耳趣談軟體(Joel on Software)導讀書摘

簡明約耳趣談軟體(Joel on Software)導讀書摘

T1.1_Sass 裝好了,可是 - -watch 不能用?

T1.1_Sass 裝好了,可是 - -watch 不能用?

Day05 git 柳暗花明

Day05 git 柳暗花明


Comments